#include "testsumservice.h"

TestSumService::TestSumService()
{
}

void  TestSumService::testExecute()
{
    QByteArray result;
    int num1 = 6;
    int num2 = 8;
    int sum = num1 + num2;


    {
        QByteArray block;
        QDataStream out(&block, QIODevice::WriteOnly);
        out << QString("SUM")  << num1 << num2;
        SumService sumService;
        QDataStream in(block);
        result = sumService.execute(in);
    }

    QByteArray expected;

    {
        QDataStream out2(&expected, QIODevice::WriteOnly);
        out2 << quint16(0) << QString("RESULT") << sum;
        out2.device()->seek(0);
        out2 << quint16(expected.size() - sizeof(quint16));
    }

    QCOMPARE(result, expected);
}
